home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************/
- /* */
- /* TOY-PROLOGshell */
- /* <c> Dr. Sarnow */
- /* für die PD der ST-Computer */
- /* zum persönlichen Gebrauch freigegeben */
- /* */
- /********************************************************************/
-
- #include <obdefs.h>
- #include <gemdefs.h>
- #include <osbind.h>
- #include <stdio.h>
- #include <string.h>
- #include "proshell.h"
-
- #define TRUE (1)
- #define FALSE (0)
- #define DEBUG
-
- /*************************** idiotisches GEM Geblasel **************/
- int contrl[12],
- intin[128],
- intout[128],
- ptsin[128],
- ptsout[128] ;
-
- int work_in[12],
- work_out[57] ;
- int pxyarray[10] ;
-
- int handle ;
- OBJECT *menu_tree,*formular,*urheber,*optfiles;
-
- FILE *optfilebuffer;
-
- int mouse ; /* mouse ein = 1, aus = 0 */
- int gl_dummy ; /* globaler dummy */
- int dix,diy,diw,dih ; /* dialog box parameter */
- int x_info,y_info,w_info,h_info;
- int x_opt,y_opt,w_opt,h_opt;
- int obval;
- int xwork,ywork,wwork,hwork;
- int xfull,yfull,wfull,hfull;
-
- int msgbuff[32] ;
-
- char options[7][20],d[20],lspfile[20],was[30],akt[13],pf[150],*xlopt;
-
-
- /* globale Variablen für den Gebrauch der Window Routinen aus der */
- /* MEGAMAX Tool Diskette Nr. 4*/
-
- static int whandle[5] ; /* window-handle fuer max. 4 fenster */
- static int ax[5],ay[5],aw[5],ah[5] ; /* koord. der arbeitsbereiche */
- static int bx[5],by[5],bw[5],bh[5] ; /* koord. der bildbereiche */
- static int posx[5],posy[5] ; /* koord. des linken oberen eckpkts */
- /* im virtuellen fenster */
- static int fulled[5] ; /* fenster fulled oder nicht */
- static int wikind[5] ; /* fensterattribute */
- static int wopen[5] ; /* fenster offen oder zu */
- static char *speich[5] ; /* anfangsadressen der speicherbereiche */
- static char *base[5] ; /* anfangsadressen der screens */
- static int maxwd ; /* nummer des hoechsten windows muss zu anfang auf 0
- gesetzt werden */
- static char *bild ;
- static int mwidth,mheight,mplane ;
- static int wd_handle ;
-
- /************** Öffnet virtuelle Arbeitstation ************/
-
- open_vwork()
- {
- int i,dummy;
- appl_init();
- handle=graf_handle(&gl_dummy,&gl_dummy,&gl_dummy,&gl_dummy);
- for (i=0;i<10;work_in[i++]=1);
- work_in[10]=2;
- v_opnvwk(work_in,&handle,work_out);
- graf_mouse(0,&gl_dummy) ;
- }
-
- /******************* Schließt dieselbe *********************/
-
- close_vwork()
- {
- v_clsvwk(handle);
- appl_exit();
- Pterm0();
- }
-
- /********************** Maus an *****************************/
-
- show_mouse()
- { if (!mouse)
- { graf_mouse(257,&gl_dummy) ;
- mouse = TRUE ;
- }
- }
-
- /*************** Und wieder aus ********************************/
-
- hide_mouse()
- { if (mouse)
- { graf_mouse(256,&gl_dummy) ;
- mouse = FALSE ;
- }
- }
-
- /*************************************************************/
- /* hauptprogramm */
- /*************************************************************/
-
- main()
- {
- int reso ;
- open_vwork() ;
- if (!rsrc_load("proshell.rsc"))
- {
- form_alert(1,"[3][Ich kann PROSHELL.RSC nicht finden !][Abbruch]");
- close_vwork();
- }
- if (!rsrc_gaddr(0,LEISTE,&menu_tree))
- {
- form_alert(1,"[3][Resource File nicht ok !][Abbruch]");
- close_vwork();
- }
-
- if (!Getrez()==2)
- {
- form_alert(1,"[3]['tschuldigung,|funktioniert nur|mit hoher|Auflösung.][ Meinetwegen ]");
- close_vwork();
- }
-
- /* variablen setzen */
-
- mouse = TRUE ; /*Maus an*/
- xlopt=malloc(310); /*Speicherplatz für Hilfsstring bereitstellen*/
- strcpy(pf,"A:\\*.*"); /*Setze Pfad String auf das*/
- *pf=Dgetdrv()+65; /*aktuelle Laufwerk*/
- menu_bar(menu_tree,TRUE) ; /*Menüleiste anzeigen*/
- rsrc_gaddr(R_TREE,KNOEPFE,&formular); /* Adresse des Formulars holen*/
- strcpy(lspfile,"TEST"); /*Setze Default Prolog File*/
- (((TEDINFO *)(formular[PROFILE].ob_spec))->te_ptext)=lspfile; /*Objektkomponenete->te_ptext zeigt auf
- /* den String lispfile*/
- form_center(formular,&dix,&diy,&diw,&dih);/*Zentriere das Formular*/
- rsrc_gaddr(R_TREE,AUTOR,&urheber);/*Hol die Adresse der Infoschablone*/
- form_center(urheber,&x_info,&y_info,&w_info,&h_info); /*und zentriere sie*/
- rsrc_gaddr(R_TREE,OPTFILES,&optfiles);/*Hol die Adresse der Hilfsfileschablone*/
- (((TEDINFO *)(optfiles[NAME1].ob_spec))->te_ptext)=options[0];/*und verbiege alle Stringpointer*/
- (((TEDINFO *)(optfiles[NAME2].ob_spec))->te_ptext)=options[1];/*sodaß sie auf die Strings für die*/
- (((TEDINFO *)(optfiles[NAME3].ob_spec))->te_ptext)=options[2];/*Files zeigen*/
- (((TEDINFO *)(optfiles[NAME4].ob_spec))->te_ptext)=options[3];
- (((TEDINFO *)(optfiles[NAME5].ob_spec))->te_ptext)=options[4];
- (((TEDINFO *)(optfiles[NAME6].ob_spec))->te_ptext)=options[5];
- (((TEDINFO *)(optfiles[NAME7].ob_spec))->te_ptext)=options[6];
- form_center(optfiles,&x_opt,&y_opt,&w_opt,&h_opt);/*Zentriere das Formular*/
- wind_get(0,WF_WORKXYWH,&xfull,&yfull,&wfull,&hfull);/*Hol die Fensterkoordinaten*/
- wikind[1]=NAME | INFO;/*FEnsterelemente festlegen*/
- wind_calc(WC_WORK,wikind[1],xfull,yfull,wfull,hfull,&xwork,&ywork,&wwork,&hwork);/*Berechne Koordinaten*/
- /*für den Arbeitsbereich*/
- maxwd=0;/* Ist angeblich für die FEnsterroutinen erforderlich*/
- wd_init(handle);/*Initialisiere die Fensterroutinen der MM-Window_routinen*/
- whandle[1]=wd_open(wikind[1],xwork,ywork,wwork,hwork);/*Öffne das Fenster*/
- wd_title(whandle[1],"TOY-PROLOGshell");/*Text für Titelzeile ausgeben*/
- wd_info(whandle[1]," \275 Dr. Sarnow");
- /*Text für Infozeile ausgeben*/
- wd_clr(whandle[1]);/*Lösche Fensterinhalt*/
- wd_update(whandle[1]);/*Aktualisiere Fensterinhalt*/
- multi() ;/*Verwaltet alle Ereignisse*/
-
- }
-
- multi()
- { int event,mx,my,dummy,keycode;
- char *hilfe;
-
- do
- {
- objc_draw(formular,0,MAX_DEPTH,dix,diy,diw,dih);/*Zeichne das Formular neu*/
- event = evnt_multi(MU_KEYBD | MU_BUTTON | MU_MESAG, /*Warten auf...*/
- 1,1,1,
- FALSE,0,0,0,0,
- FALSE,0,0,0,0,
- msgbuff,0,0,
- &mx,&my,&dummy,&dummy,&keycode,&dummy) ;
-
- wd_redraw(msgbuff);/*Automatischer Redraw Befehl (MMTOOL4)*/
-
- if (event & MU_MESAG) /*Menüleiste gewählt*/
- { switch(msgbuff[0])
- { case MN_SELECTED : do_menu(msgbuff[3],msgbuff[4]) ;
- break ;
-
- }
- }
-
- /* weitere abfragen */
- if (event & MU_BUTTON)
- {
- obval=objc_find(formular,0,MAX_DEPTH,mx,my);/*Finde angeklicktes Objekt*/
- menu_bar(menu_tree,FALSE);/*Menüleiste aus*/
- switch(obval)
- {
- case PROLOG:/* Es war der TOY-PROLOG-Knopf*/
- wd_close(whandle[1]);/*Fenster dicht*/
- hide_mouse();
- optfilebuffer=fopen("optionen","w");/*Leider akzeptiert */
- strcpy(xlopt,"['"); /*TOY-Prolog keine*/
- xlopt=strcat(xlopt,lspfile); /*Parameter. Deshalb*/
- xlopt=strcat(xlopt,"'"); /*der Umweg über */
- for (dummy=0;dummy<7;dummy++) /*eine externe Datei.*/
- {
- if (strlen(options[dummy])>1)
- {
- xlopt=strcat(xlopt,",'");
- xlopt=strcat(xlopt,options[dummy]);
- xlopt=strcat(xlopt,"'");
- }
- }
- xlopt=strcat(xlopt,"]");
- fprintf(optfilebuffer,"%s\n",xlopt);
- fclose(optfilebuffer);
- Pexec(0,"toy.prg","",0L); /*Los geht's*/
- show_mouse();
- graf_mouse(0,0L);
- wd_display(whandle[1],xfull,yfull,wfull,hfull);/*Fenster auf*/
- break;
-
- case EDITOR: /*Wie bei TOY-PROLOG*/
- wd_close(whandle[1]);
- strcpy(xlopt," ");
- xlopt=strcat(xlopt,lspfile);
- hide_mouse();
- Pexec(0,"editor.prg",xlopt,0L);
- show_mouse();
- wd_display(whandle[1],xfull,yfull,wfull,hfull);
- break;
-
- case OPTIONEN: /*Wähle Optionsfile*/
- keycode=opt();/*Welcher Button wird gedrückt?*/
- strcpy(d,options[keycode]); /*Auswahl erfolgt mit*/
- strcpy(was," Prolog Hilfsfile wählen "); /*Hilfe der File Selector-Routine*/
- strcpy(akt," OK "); /*aus der MM-tool Diskette 4*/
- file_select(pf,d,was,akt,"*.PRO","*.*","*.*","*.*",2);/*Aufruf derselben*/
- if ((hilfe=index(d,'.'))!=NULL && strcmp(++hilfe,"TOY")==0)
- {
- form_alert(1,"[3][*.TOY Files müssen mit|sysload(Name)|geladenwerden][Grummel]");
- }
- else
- {
- strcpy(options[keycode],d);/*gewählte Datei festhalten*/
- }
- break;
-
-
- case PROFILE: /*Prolog Workfile wählen*/
- strcpy(d,lspfile);/*sonst wie bei Options*/
- strcpy(was," Prolog File wählen ");
- strcpy(akt," OK ");
- file_select(pf,d,was,akt,"*.PRO","*.*","*.*","*.*",2);
- if ((hilfe=index(d,'.'))!=NULL && strcmp(++hilfe,"TOY")==0)
- {
- form_alert(1,"[3][*.TOY Files müssen mit|sysload(Name)|geladenwerden][Grummel]");
- }
- else
- {
- strcpy(lspfile,d);
- }
- break;
-
- case CIAO: /*Tschüs, au revoir, good bye*/
- wd_delete(whandle[1]);
- rsrc_free();
- show_mouse();
- close_vwork();
- break;
- }
- menu_bar(menu_tree,TRUE);
- }
-
- }while(TRUE) ;
-
- } /* multi */
-
- do_menu(title,item)/*Routine führt die in der Menüleiste gewählte*/
- int title,item ; /*Routine aus. Hat hier nicht viel zu tun*/
- { switch(title)
- { case DESK :
- switch(item)
- { case INFORM : info() ; break ;
- }
-
- }
- menu_tnormal(menu_tree,title,1) ;/*Menütitel wieder normal zeichnen*/
-
- } /* do menu */
-
- info() /*Zeige das Info-formular*/
- {
- form_dial(FMD_START,320,200,0,0,x_info,y_info,w_info,h_info);
- form_dial(FMD_GROW,320,200,0,0,x_info,y_info,w_info,h_info);
- objc_draw(urheber,0,20,x_info,y_info,w_info,h_info);
- objc_change(urheber,INFOEX,0,x_info,y_info,w_info,h_info,(NORMAL | OUTLINED | SHADOWED),1);
- form_do(urheber,0);
- form_dial(FMD_SHRINK,320,200,0,0,x_info,y_info,w_info,h_info);
- form_dial(FMD_FINISH,320,200,0,0,x_info,y_info,w_info,h_info);
- }
-
- opt()
- {
- int wahl;
- char *str;
-
- form_dial(FMD_START,320,200,0,0,x_opt,y_opt,w_opt,h_opt);/*Zeige das Formular*/
- form_dial(FMD_GROW,320,200,0,0,x_opt,y_opt,w_opt,h_opt); /*für die Wahl der Hilfs-*/
- objc_draw(optfiles,0,20,x_opt,y_opt,w_opt,h_opt); /*routinen*/
- form_do(optfiles,0);
- form_dial(FMD_SHRINK,320,200,0,0,x_opt,y_opt,w_opt,h_opt);
- form_dial(FMD_FINISH,320,200,0,0,x_opt,y_opt,w_opt,h_opt);
- wahl=dialog_wahl(optfiles,BUTTON1,BUTTON7);/*finde den gedrückten Knopf (aus MMtool 4)*/
- objc_change(optfiles,wahl,0,x_opt,y_opt,w_opt,h_opt,NORMAL,0);/*Stelle ihn wieder normal dar*/
- switch (wahl) /*Leider haben nicht alle Objekte den gleiche Offset*/
- {
- case BUTTON1:
- wahl=0;
- break;
-
- case BUTTON2:
- wahl=1;
- break;
-
- case BUTTON3:
- wahl=2;
- break;
-
- case BUTTON4:
- wahl=3;
- break;
-
- case BUTTON5:
- wahl=4;
- break;
-
- case BUTTON6:
- wahl=5;
- break;
-
- case BUTTON7:
- wahl=6;
- break;
-
- }
- return(wahl);
- }
-
-